package com.ysx.oa.hl.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.ysx.oa.hl.service.CalculatorService;
import com.ysx.oa.hl.utils.HttpClientUtil;
import org.springframework.stereotype.Service;

@Service
public class CalculatorImpl implements CalculatorService {

    //@Autowired
    //private RoleService roleService;

    @Override
    public int sum(int x, int y) throws Exception {


        //1 组装参数
        String url="http://localhost:8080/kaoqin/role/sum.do?x="+x+"&y="+y;

        //2 调用老师的工具类得到json对象 HttpClient
        JSONObject jsonObject = HttpClientUtil.call(url);

        //3 处理自己的逻辑
        Object obj = jsonObject.get("data");
        Integer sum =(Integer)obj;
        return sum;
    }
}
